home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_lag_torpedo.cog < prev    next >
Text File  |  1999-11-15  |  12KB  |  426 lines

  1. # Jones 3D Cog Script
  2. #
  3. # lag_torpedo.cog
  4. #
  5. #
  6. # [DS]
  7. #
  8. # (C) 1999 LucasArts Entertainment Co. All Rights Reserved
  9. # ========================================================================================
  10.  
  11. symbols
  12.     message    startup
  13.     message    entered
  14.     message    exited
  15.     message    pulse    
  16.     message    activate
  17.     message    timer
  18.     message    callback
  19.  
  20.       thing        torpedo
  21.     thing        indyactor
  22.     thing        campos0
  23.     thing        campos1
  24.     thing        jumppos
  25.     thing        inviso_torp
  26.     surface        shipwall
  27.     surface        sandsurf
  28.     cog            hints            #send message when complete. 
  29.  
  30.     thing        expos
  31.     int            pieces=20                local
  32.     int            k                        local
  33.     int            fragment                local
  34.     int            see_snd                    local
  35.     int            doplay=0                local
  36.     template    debris0=metalshrapa        local         
  37.     template    debris1=metalshrapb        local           
  38.     template    debris2=metalshrapc        local         
  39.     template    debris3=metalshrapa        local         
  40.     template    debris4=metalshrapb        local
  41.  
  42.     int            lined_up                    local
  43.     int            spoken=0                    local
  44.     int            direction=0                    local
  45.     int            torpdir=0                    # desc=0-north,1-south,2-east,3-west.
  46.     int            played=0                    local
  47.     sound        torpstart=lag_torp_start_c.wav        local    
  48.     sound        torpunder=lag_torp_under_c.wav        local    
  49.     sound        torpexpl=lag_torp_explo_c.wav        local    
  50.     sound        torpadjust=lag_torp_adjust_c.wav    local    
  51.     sound        torparm=lag_torp_arm_c.wav            local    
  52.     sound        torpsplsh=lag_torp_splash_c.wav        local    
  53.  
  54.     int        blown=0                    local
  55.     int        curcam                    local
  56.     keyframe    in_activate=in_torpedo_launch.key    local
  57.     keyframe    torp_start=torpedo_launch.key        local
  58.     keyframe    torp_fwd=torpedo_fwd.key            local
  59.     keyframe    in_bothup=0in_armsup_1_1.key        local
  60.     vector    vec1                    local
  61.     vector    lookvec                    local
  62.  
  63.  
  64. #-------- Torpedo bubbles ---------------------------------
  65.  
  66.     thing        bubble                    local
  67.     template    bubble0=+bubbles        local
  68.     vector        startBubble                local
  69.     vector        finBubble                local
  70.     vector        bubbleVel                local
  71.     int            i=0                        local
  72.     int            blurps=5                local
  73.  
  74. #-------- Underwater explosion ----------------------------
  75.     template    tplExplode=+uw_blast        local
  76.     template    tplBubble=+bubbles            local
  77.     template    x=+uw_spr_blast                local
  78.     template    y=+uw_spr_explode            local
  79.     thing        bubs                        local
  80.     int            j                            local
  81.     vector        bubsVel                        local
  82.  
  83.     keyframe    in_reach=in_activate_low.key        local
  84.  
  85. #.............. INDY SAY LINES ..................................................
  86.     sound        seetorp=lg03j01.wav    local    #A torpedo. And it's still in good shape..
  87.     sound        movtorp=lg03j05.wav    local    #I'll just aim this tin fish over here..
  88.     sound        armtorp=inxj112.wav    local    #That ought to do it..
  89.  
  90. # no item line...    
  91.     sound        trytorp=lg03j04.wav    local    #This torp. needs an arming device..
  92.  
  93. # wrong item...
  94.     sound    in_itemline0=Inxj089.wav        local # That didn't work.
  95.     sound    in_itemline1=Inxj090.wav        local # ...something wrong.
  96.     sound    in_itemline2=Inxj092.wav        local # Hmm...didn't quite work.
  97.     sound    in_itemline3=Inxj060.wav        local # I don't think...right answer.
  98.     sound    in_itemline4=Inxj087.wav        local # Whoops.
  99.     sound    in_itemline5=Inxj088.wav        local # Nope.
  100.     sound    in_itemline6=Inxj091.wav        local # Of course that didn't work.    
  101.     int        wi_newline=50                    local
  102.     int        wi_oldline=50                    local
  103.     int        lineindex                        local # indexes sound array
  104.  
  105.     int        wrongitemoffset                    local
  106.     flex    randwrongitemlines                local
  107.     flex    explode                            local
  108.     flex    notlinedup                        local
  109.     int        under_snd                        local
  110.     int        speak0                            local
  111.     int        playerx                            local
  112.     vector    playervec                        local
  113.     thing    player                            local
  114.     int        playery                            local
  115.  
  116. # wrong spot...
  117.     sound    in_wrongspot0=Inxj219.wav        local # Not lined up right
  118.     sound    in_wrongspot1=Inxj220.wav        local # Need to line up
  119.     sound    in_wrongspot2=Inxj221.wav        local # Need to move over.
  120.     sound    in_wrongspot3=Inxj222.wav        local # Not quite in position.
  121.     sound    in_wrongspot4=Inxj223.wav        local # Need to get in position.
  122.     sound    in_wrongspot5=Inxj224.wav        local # Need to find better spot.
  123.     int        l_newline=0                        local
  124.     int        l_oldline=0                        local
  125.  
  126.  
  127. end
  128.  
  129. # ========================================================================================
  130.  
  131. code
  132. startup:
  133.     player=GetLocalPlayerThing(); 
  134.     vec1 = VectorSet(5.96513, -21.0744, -0.779346);
  135.     lookvec = VectorSet(0, -1, 0);
  136.     setpulse(0.0);
  137.     return;
  138.  
  139. #---------------Ready?------------------------------------------------------------
  140.  
  141. entered:
  142.     if(GetSenderRef() != sandsurf)
  143.     {
  144.         return;
  145.     }
  146.     lined_up=1;
  147.     if (spoken == 1)
  148.     {
  149.         return;
  150.     }
  151.     setpulse(0.5);
  152.     return;
  153.  
  154. exited:
  155.     if(GetSenderRef() != sandsurf)
  156.     {
  157.         return;
  158.     }
  159.     lined_up=0;
  160.     if (spoken == 1)
  161.     {
  162.         return;
  163.     }
  164.     setpulse(0.0);
  165.     return;
  166.  
  167. #---------------Ready?------------------------------------------------------------
  168.  
  169. pulse:
  170.  
  171.     if (spoken == 0)
  172.     {
  173.         playervec = GetThingLVec(player);
  174.         playery = VectorY(playervec);
  175.         playerx = VectorX(playervec);
  176.  
  177.         if ((playery > 0) && ((playerx > -0.7) && (playerx < 0.7)))
  178.         {
  179.             direction = 0;                               //north
  180.         }
  181.         else if ((playery < 0) && ((playerx > -0.7) && (playerx < 0.7)))
  182.         {
  183.             direction = 1;                          //south
  184.         }
  185.         else if ((playerx > 0) && ((playery > -0.7) && (playery < 0.7)))
  186.         {
  187.             direction = 2;                          //east
  188.         }
  189.         else if ((playerx < 0) && ((playery > -0.7) && (playery < 0.7)))
  190.         {
  191.             direction = 3;                          //west
  192.         }
  193.         if ((direction) == (torpdir))
  194.         {
  195.             see_snd=PlayVoice(player, seetorp, 1.0, 0);
  196.             spoken=1;
  197.         }
  198.     }
  199.     return;
  200.  
  201. #===========Arm Torpedo========================================================
  202. Activate:
  203.     if(GetsenderRef() != torpedo)
  204.     {
  205.         return;
  206.     }
  207.     StopSound(see_snd, 0.1);
  208.     spoken=1;
  209.     if(GetCurItem(player) == 60)                #arming device.
  210.     {
  211.         if(lined_up == 1)
  212.         {
  213.             if (isMoving(torpedo)) return;
  214.             curcam = GetCurrentCamera();
  215.             MakeMeStop();
  216.             StartCutscene(1);
  217.             DeselectWeaponWait(player);
  218.             CopyPlayerHolsters(player, indyactor);
  219.             SetThingFlags(player, 0x80000);
  220.             ClearThingFlags(indyactor, 0x80000);
  221.             SetCameraLookInterp(2, 0);            # turns off interp to lookthing.
  222.             SetCameraFocus(2, campos0);
  223.             SetCameraSecondaryFocus(2, torpedo);
  224.             SetCurrentCamera(2);
  225.             SetCameraFOV(90, 0, 0);                # makes sure set to default.
  226.             PlayVoice(indyactor, movtorp, 1.0, 0);
  227.             ChangeInv(player, 60, -1);
  228.             PlayKey(indyactor, in_activate, 4, 0x12, 0);
  229.             PlayKey(torpedo, torp_start, 4, 0x12, 0);
  230.             sleep(1.0);
  231.             PlaySoundThing(torpadjust, torpedo, 1.0, 10.0, 20.0, 0);
  232.             sleep(3.1);
  233.             PlaySoundThing(torparm, torpedo, 0.8, 10.0, 20.0, 0);
  234.             sleep(1.0);
  235.             PlaySoundThing(torpstart, torpedo, 1.0, 10.0, 20.0, 0);
  236.             Sleep(1.0);
  237.             PlaySoundLocal(torpsplsh, 0.8, 0.8, 0x0, 1);
  238.             PlayVoice(indyactor, armtorp, 1.0, 0);
  239.             SetCameraLookInterp(2, 1);
  240.             sleep(0.1);
  241.             SetCameraInterpSpeed(2, 1.5);
  242.             SetCameraSecondaryFocus(2, jumppos);
  243.             return;
  244.         }
  245.         else
  246.         {
  247.             SetActorFlags(player, 0x200000);
  248.             StopThing(Player);
  249.             DeselectWeaponWait(player);
  250.             StartCutscene(0);
  251.             call notlinedup;
  252.             return;
  253.         }
  254.     }
  255.     else
  256.     {
  257.         SetActorFlags(player, 0x200000);
  258.         StopThing(Player);
  259.         DeselectWeaponWait(player);
  260.         StartCutscene(0);
  261.         PlayKey(player, in_reach, 4, 0x12, 0);
  262.  
  263.         # player is using a wrong item
  264.  
  265.         if (GetCurItem(player) >= 1)
  266.         {
  267.             sleep(1.0);
  268.             call randwrongitemlines;
  269.         }
  270.  
  271.         # player isn't using anything
  272.  
  273.         else
  274.         {
  275.             sleep(1.0);
  276.             speak0=PlayVoice(indyactor, trytorp, 1.0, 1);
  277.         }
  278.         if(speak0 > -1)
  279.             WaitForSound(speak0);
  280.         EndCutscene();
  281.         ClearActorFlags(player, 0x200000);
  282.         return;
  283.     }
  284.     return;
  285.  
  286. callback:                    #wait for torp starting animation
  287.     SetTimer(0.1);
  288.     TeleportThing(torpedo, jumppos);
  289.     AISetLookThing(indyactor, expos);
  290.     SetThingLook(torpedo, lookvec);
  291.     SetCameraLookInterp(2, 0);            #reset default
  292.     SetCameraInterpSpeed(2, 1);            #reset default
  293.     SetCameraSecondaryFocus(2, torpedo);
  294.     PlayKey(torpedo, torp_fwd, 4, 0x10, 0);
  295.     under_snd=PlaySoundThing(torpunder, torpedo, 1.0, 10.0, 60.0, 0x0081);
  296.     SetCameraFocus(2, campos1);
  297.     SetCameraFOV(45, 1, 3);
  298.     MoveThingToPos(torpedo, vec1, 3.0);
  299.     SetCameraFOV(90, 0, 0);                # makes sure set to default.
  300.     sleep(3.0);
  301.     SetFaceGeoMode(shipwall, 0);
  302.     SetAdjoinFlags(shipwall, 2);
  303.     stopsound(under_snd, 0.1);
  304.     PlaySoundThing(torpexpl, torpedo, 1.0, 30.0, 60.0, 0);
  305.     SetCameraSecondaryFocus(2, expos);
  306.     blown=1;
  307.     SendMessage(hints, user1);
  308.     destroything(torpedo);
  309.     destroything(inviso_torp);
  310.     call explode;
  311.     for(k=0; k<pieces; k=k+1)                                                                        
  312.     {
  313.         SetPOVShake('0.0 0.02 0.05', '0.0 0.0 0.0', 80.0, 0.80);
  314.         fragment = CreateThing(debris0[RandBetween(0, 4)], expos);                                 
  315.         SetThingVel(fragment, VectorScale(VectorAdd(RandVec(), '-0.5 -0.5 -0.2'), 3));
  316.         SetThingRotVel(fragment, VectorScale(VectorAdd(RandVec(), '0.0 0.0 0.0'), 300.0));
  317.         sleep(0.025);
  318.     }
  319.     sleep(1.0);
  320.     CopyOrientAndPos(Indyactor, player);
  321.     EndCutscene();
  322.     SetCurrentCamera(curcam);
  323.     SetThingFlags(indyactor, 0x80000);
  324.     ClearActorFlags(player, 0x200000);
  325.     ClearThingFlags(player, 0x80000);
  326.     return;
  327.  
  328. timer:
  329.     if(blown == 1) return;
  330.     for(i=0; i<blurps; i=i+1)                                                                        
  331.     {                                                                                                    
  332.         bubble = CreateThing(bubble0, torpedo);
  333.         bubbleVel=VectorSet(0,0,rand()+0.25);
  334.         SetThingVel(bubble, VectorScale(bubbleVel, 0.2));
  335.         startBubble = VectorSet(0.01, 0.01, 1.0);
  336.         finBubble = VectorSet(0.1, 0.1, 0.0);
  337.         AnimateSpriteSize(bubble, startBubble, finBubble, rand()*4.0+2.0);
  338.     }
  339.     SetTimer(0.05);
  340.     return;   
  341.  
  342. #------ underwater explosion ---------------------------------------------
  343. explode:
  344.     CreateThing(tplExplode, expos);
  345.     Sleep(0.25);
  346.     for (j = 0; j < 50; j = j + 1)
  347.     {
  348.     # Make a bubble
  349.         bubs = CreateThing(tplBubble, expos);
  350.     # Set the life left to a random value
  351.         SetLifeLeft(bubs, Rand() * 20.0);
  352.     # Set it to die when it hits air
  353.         SetThingFlags(bubs, 0x10000000);
  354.     # Animate the bubble sprite
  355.         AnimateSpriteSize(bubs, '0.001 0.001 1.0', '0.06 0.06 1.0', 0.5);
  356.     # Set the bubble to a random velocity
  357.         bubsVel = VectorSet(Rand() - 0.35, Rand() - 0.35, Rand() + 0.5);
  358.         bubsVel = VectorScale(bubsVel, 0.4);
  359.         if (Rand() < 0.5)
  360.         {
  361.             bubsVel = VectorSet(-VectorX(bubsVel), VectorY(bubsVel), VectorZ(bubsVel));
  362.         }
  363.         if (Rand() < 0.5)
  364.         {
  365.             bubsVel = VectorSet(VectorX(bubsVel), -VectorY(bubsVel), VectorZ(bubsVel));
  366.         }
  367.         SetThingVel(bubs, bubsVel);
  368.     }
  369.     return;
  370. #=====================================================================
  371. #        Wrong Item lines
  372. #=====================================================================
  373. randwrongitemlines:
  374.  
  375.     while (wi_newline == wi_oldline)
  376.     {        
  377.         wi_newline = RandBetween(0, 19);
  378.         if (wi_newline < 15)
  379.         {    
  380.             wi_newline = RandBetween(0, 3); # ~1/5 chance for lines 0 thru 3
  381.         }
  382.         if (wi_newline == 19)
  383.         {
  384.             wi_newline = 6; # 1/20 chance for line 6 
  385.         }
  386.         if (wi_newline > 16)
  387.         {
  388.             wi_newline = 5; # 1/10 chance for line 5 
  389.         }
  390.         if (wi_newline > 14)
  391.         {
  392.             wi_newline = 4; # 1/10 chance for line 4
  393.         }
  394.     }
  395.     wi_oldline = wi_newline;    
  396.     lineindex = wrongitemoffset + wi_newline;
  397.     speak0 = PlayVoice(player, in_itemline0[lineindex], 1, 1);
  398.     return;
  399.  
  400. #=====================================================================
  401. #        Not Lined Up.
  402. #=====================================================================
  403. notlinedup:
  404.     while (l_newline == l_oldline)
  405.     {        
  406.         l_newline = RandBetween(0, 5);
  407.     }
  408.     l_oldline = l_newline;
  409.     
  410.     speak0 = PlayVoice(player, in_wrongspot0[l_newline], 1, 0);
  411.  
  412.     doplay = Randbetween(0, 2);
  413.     if ((doplay == 0) || (played == 0))
  414.     {
  415.         PlayKey(player, in_bothup, 4, 0x12, 0);
  416.         played = 1;
  417.     }
  418.     WaitForSound(speak0);
  419.     EndCutscene();
  420.     ClearActorFlags(player, 0x200000);
  421.     return;
  422.  
  423.  
  424. end
  425.  
  426.